import request from "@/utils/request";
import { ActivityNodeForm, ActivityNodeVO } from "./activityNode.api";

const BASE_URL = "/system/activity";

const ActivityAPI = {
  /**
   * 根据id查询
   */
  load(id: string) {
    return request<any, ActivityDetail>({
      url: `${BASE_URL}/loadDetail?id=${id}`,
      method: "get",
    });
  },
  /**
   * 修改流程
   * @param data 流程表单数据
   */
  update(data: ActivityForm) {
    return request<any, boolean>({
      url: `${BASE_URL}/update`,
      method: "post",
      data,
    });
  },
};

export default ActivityAPI;

/** 实例分页对象 */
export interface ActivityPageVO {
  /** ID */
  id: string;
  /** 流程模板ID */
  flowId: string;
  /** 名称 */
  name: string;
  /** 描述 */
  remark: string;
  /** 创建人 */
  userId: string;
  username: string;
  /** 当前节点id */
  currentNodeId: string;
  /** 创建时间 */
  createTime: string;
  /** 结束时间 */
  endTime: string;
  /** 状态 */
  status: string;
  /** 关联ID */
  relatedId: string;
  /** 关联类型 */
  relatedType: string;
}

export interface ActivityDetail extends ActivityPageVO {
  currentNodeName: string;
  statusName: string;
  activityNodes: ActivityNodeVO[];
}

export interface ActivityForm {
  id: string;
  name: string;
  activityNodes: ActivityNodeForm[];
}
